package com.example.mysdktest.activities;

import android.graphics.Color;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.mysdktest.R;
import com.example.mysdktest.base.BaseActivity;
import com.xm9m.ibczy.dsp.AdvertFactory;
import com.xm9m.ibczy.dsp.utils.AntLog;

/**
 * Created by baichuan on 2016/11/22.
 */

public class HttpAnt extends BaseActivity implements View.OnClickListener {
    private LinearLayout layout;
    private Button add, add2, add3;


    @Override
    public int getLaout() {
        return R.layout.ac_httpant_layout;
    }

    @Override
    public void initView() {
        layout = (LinearLayout) findViewById(R.id.ac_http_ant_lnl001);
        add = (Button) findViewById(R.id.ac_http_ant_obt001);
        add2 = (Button) findViewById(R.id.ac_http_ant_obt002);
        add3 = (Button) findViewById(R.id.ac_http_ant_obt003);
        AntLog.i(Thread.currentThread().getName());

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        add.setOnClickListener(this);
        add2.setOnClickListener(this);
        add3.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ac_http_ant_obt001:
                addView01();
                break;
            case R.id.ac_http_ant_obt002:
                addview02();
                break;
            case R.id.ac_http_ant_obt003:
                addView03();
                break;
        }
    }

    private void addView01() {
        View banner = AdvertFactory.getView(this);
        TextView txt = new TextView(this);
        txt.setBackgroundColor(Color.GRAY);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.height = 1;
        layout.addView(banner);
        layout.addView(txt, params);
    }

    private void addview02() {
        View banner = AdvertFactory.getView2(this);
        TextView txt = new TextView(this);
        txt.setBackgroundColor(Color.GRAY);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.height = 1;
        layout.addView(banner);
        layout.addView(txt, params);
    }

    private void addView03() {
        View banner = AdvertFactory.getView3(this);
        TextView txt = new TextView(this);
        txt.setBackgroundColor(Color.GRAY);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        params.height = 1;
        layout.addView(banner);
        layout.addView(txt, params);
    }

}
